A substrate where a semiconductor device is formed may include a locally high region and a locally low region on the substrate. Exposing the substrate with such a height difference causes a difference in best focus between the regions with the different heights. In such a case, the defocus due to the height difference between patterns can be reduced by setting the focus that is appropriate in accordance with the height difference.
In a case where the regions have a constant height difference and patterns with different densities between these regions are disposed, exposure is performed after the spherical aberration is adjusted, so that the difference in best focus between the regions can be reduced.
However, if the height between the patterns varies for each of substrates with various pattern densities, the optimum value of the spherical aberration for reducing the difference in best focus between the patterns varies. In this case, the amount of defocus of each pattern increases because of the height difference between the patterns.